package com.woniuxy.aop.service.impl;

import com.woniuxy.aop.bean.Perm;
import com.woniuxy.aop.mapper.PermMapper;
import com.woniuxy.aop.service.IPermService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author linke
 * @version 1.0
 * @className: PermServiceImpl
 * @description: 用户服务实现类
 * @date 2021/11/13 10:36
 * @Service注解将实现类交给sprin容器管理
 * @Transactional 只读事务声明，用于对查询事务的优化
 */
@Transactional(readOnly = true)
@Service
public class PermServiceImpl implements IPermService {
    /**
     * 注入持久层对象
     */
    @Resource
    private PermMapper permMapper;
    @Override
    public List<Perm> findAll() {
        return permMapper.findAll();
    }

    @Override
    public Perm getOneById(Integer id) {
        return permMapper.getOneById(id);
    }
    //REPEATABLE_READ可重复读取级别    在执行修改操作提交后，只允许查询
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void savePerm(Perm perm) {
        permMapper.savePerm(perm);
    }
    //REPEATABLE_READ可重复读取级别    在执行修改操作提交后，只允许查询
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void updatePerm(Perm perm) {
        permMapper.updatePerm(perm);
    }
    //REPEATABLE_READ可重复读取级别    在执行修改操作提交后，只允许查询
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void deletePerm(Integer id) {
        permMapper.deletePerm(id);
    }
}
